package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.BindTeachplanMediaDto;
import com.xuecheng.content.model.dto.SaveTeachPlanDto;
import com.xuecheng.content.model.dto.TeachPlanDto;
import com.xuecheng.content.model.po.TeachplanMedia;
import com.xuecheng.content.service.CourseTeacherService;
import com.xuecheng.content.service.TeachPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: 我在人间讲故事
 * @Version: 1.0
 * @since: 2023/6/3
 * @description: 课程计划管理相关的接口
 */
@Api(value = "课程计划编辑接口",tags = "课程计划编辑接口")
@RestController
public class TeachPlanController {


    @Autowired
    CourseTeacherService courseTeacherService;

    @Autowired
    TeachPlanService teachPlanService;

    @ApiOperation("查询课程计划树形结构")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable Long courseId){
        List<TeachPlanDto> teachPlanTree = courseTeacherService.findTeachPlanTree(courseId);
        return teachPlanTree;
    }

    @ApiOperation("课程计划创建或修改")
    @PostMapping("/teachplan")
    public void saveTeachPlan(@RequestBody SaveTeachPlanDto teachPlanDto){
        teachPlanService.saveTeachPlan(teachPlanDto);
    }


    @ApiOperation("删除课程计划")
    @DeleteMapping("/teachplan/{id}")
    public void deleteTeachPlan(@PathVariable Long id){
        teachPlanService.deleteTeachPlan(id);
    }

    @ApiOperation("课程计划排序")
    @PostMapping("/teachplan/{moveType}/{teachplanId}")
    public void orderByTeachplan(@PathVariable String moveType, @PathVariable Long teachplanId) {
        teachPlanService.orderByTeachplan(moveType, teachplanId);

    }

    @ApiOperation(value = "课程计划和媒资信息绑定")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto){
        TeachplanMedia teachplanMedia = teachPlanService.associationMedia(bindTeachplanMediaDto);

    }

    @ApiOperation(value = "课程计划接触视频绑定")
    @DeleteMapping("/teachplan/association/media/{teachplanId}/{mediaId}")
    public void disconnectMedia(@PathVariable Long teachplanId,@PathVariable String mediaId){
            teachPlanService.disconnectMedia(teachplanId,mediaId);
    }



}
